<?php

include_once 'Classes/PHPCodeProvider.php';

$options = new CodeGeneratorOptions();
$writer = new IndentedTextWriter();
$provider = new PHPCodeProvider();

/* 
 * Create an empty array
 */

$array1 = new ArrayCreateExpression();

$provider->generateCodeFromExpression($array1, $writer, $options);

echo '<pre>' . 
    str_replace('<br />', '', highlight_string($writer->get_String(), true)) 
        . '<pre/>';

/*
 * Clear the IndentedTextWriter text
 */

$writer->clear();

/*
 * Create an array with two elements
 */

$array2 = new ArrayCreateExpression();

/*
 * The first element
 */

$init1 = new BinaryOperatorExpression(BinaryOperator::KEY_VALUE);
$init1->Left = new PrimitiveExpression('won');
$init1->Right = new PrimitiveExpression(0);

$array2->Initializers->add($init1);

/*
 * The second element
 */

$init2 = new BinaryOperatorExpression(BinaryOperator::KEY_VALUE);
$init2->Left = new PrimitiveExpression('lost');
$init2->Right = new PrimitiveExpression(0);

$array2->Initializers->add($init2);

$provider->generateCodeFromExpression($array2, $writer, $options);

echo '<pre>' . 
    str_replace('<br />', '', highlight_string($writer->get_String(), true)) 
        . '<pre/>';

/*
 * The output should be:
 * 
 * array()
 *
 * array('won' => 0, 'lost' => 0)
 * 
 */

?>
